package clientproxy

import (
	"go_study/rpc-new-helloworld/hanlder"
	"net/rpc"
)

type HelloServiceStub struct {
	*rpc.Client
}

//在go中内有类，对象 意味着没法初始化,只能直接定义个方法
func NewHelloServiceClient(protol, address string) HelloServiceStub {
	conn, err := rpc.Dial(protol, address)
	if err != nil {
		panic("connect error")
	}
	return HelloServiceStub{conn}
}
func (c *HelloServiceStub) Hello(req string, reply *string) error {
	err := c.Call(hanlder.HelloServiceName+".Hello", req, reply)
	if err != nil {
		return err
	}
	return nil
}
